/*
 * Copyright 2009 Nordic Consulting & Development Company
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package pl.ncdc.web.login.client;

import pl.ncdc.web.login.client.service.AuthenticationServiceAsync;
import pl.ncdc.web.login.client.service.HttpRequestAuthenticationServiceAsync;
import pl.ncdc.web.login.client.service.UserService;
import pl.ncdc.web.login.client.service.UserServiceAsync;

import com.google.gwt.core.client.GWT;

/**
 *
 * <p>
 * Created on Jan 28, 2009
 *
 * @author hshsce
 * @version $Id: HttpPostLoginApp.java 171 2009-01-29 23:16:32Z hshsce $
 */
public class HttpPostLoginApp extends AbstractLoginApp {

	/**
	 * @see AbstractLoginApp#newAuthenticationService()
	 */
	@Override
	protected AuthenticationServiceAsync newAuthenticationService() {
		final LoginConfiguration c = getConfiguration();
		final String loginUrl = c.getUrlProperty("loginUrl", "Login");
		final String logoutUrl = c.getUrlProperty("logoutUrl", "Logout");
		final String uidParameter = c.getProperty("uidParameter", "uid");
		final String passwordParameter = c.getProperty("passwordParameter", "password");
		return new HttpRequestAuthenticationServiceAsync(loginUrl, logoutUrl, uidParameter, passwordParameter);
	}

	/** {@inheritDoc} */
	@Override
	protected UserServiceAsync newUserService() {
		//TODO user service should be also non-gwt
		return GWT.create(UserService.class);
	}

}
